import { UaCard, TriggerTypeLogoMap, TriggerStrMap, TriggerColorStrMap, CardCategoryMap } from "../../models/ua-card.model";
import { GlobalService } from "../../services/global.service";

// components/ua-card-item/ua-card-item.component.ts
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    count: {
      type: Number,
      value: 0
    },
    // 缩小状态
    small: {
      type: Boolean,
      value: false
    },
    // 展示模式/编辑模式
    display: {
      type: Boolean,
      value: false,
    },
    card: {
      type: Object,
      value: {}
    },
    // 是否是ap卡
    isAp: {
      type: Boolean,
      value: false,
    },
    // 显示效果：不是ap卡的情况下生效。
    showEffect: {
      type: Boolean,
      value: false,
    },
  },

  observers: {
    'card': function () {
      this.data.card.cardImgSm = this.data.card.cardImg.replace('.png', '.jpg');
      this.setData({ uaCard: this.data.card });
    },
  },

  /**
   * 组件的初始数据
   */

  data: {
    FILE_HOST: GlobalService.FILE_HOST,
    STATIC_ASSETS_HOST: GlobalService.STATIC_ASSETS_HOST,
    uaCard: {} as UaCard,
    TriggerTypeLogoMap: TriggerTypeLogoMap,
    TriggerStrMap: TriggerStrMap,
    TriggerColorStrMap: TriggerColorStrMap,
    CardCategoryMap: CardCategoryMap
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onIncrease: function () {
      this.triggerEvent('increase', this.data.uaCard.id)
    },
    onDecrease: function () {
      this.triggerEvent('decrease', this.data.uaCard.id)
    },
    onMax: function () {
      this.triggerEvent('max', this.data.uaCard.id)
    },
    detail: function () {
      this.triggerEvent('detail', this.data.uaCard.id)
    },
  }
})